using System;
using System.Collections.Generic;
using System.Text;
using System.Reflection;

namespace SpoonCore.Storage
{
	public class StorageManager
	{
		private readonly SortedList<int, IStorage> _storageList = new SortedList<int, IStorage>();
		private readonly string _dir;

		public StorageManager(string dir)
		{
			_dir = dir;
		}

		public Storage<T> GetStoreage<T>() where T: AbstractStorageItem, new()
		{
			Type t = typeof (T);
			if (!_storageList.ContainsKey(t.FullName.GetHashCode())) _storageList.Add(t.FullName.GetHashCode(), new Storage<T>(_dir));
			return (Storage<T>) _storageList[t.FullName.GetHashCode()];
		}
	}
}
